package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DwTaskContent;
import com.ruoyi.system.service.IDwTaskContentService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 考核内容Controller
 * 
 * @author ruoyi
 * @date 2024-01-19
 */
@RestController
@RequestMapping("/system/content")
public class DwTaskContentController extends BaseController
{
    @Autowired
    private IDwTaskContentService dwTaskContentService;

    /**
     * 查询考核内容列表
     */
    @PreAuthorize("@ss.hasPermi('examine:content:list')")
    @GetMapping("/list")
    public TableDataInfo list(DwTaskContent dwTaskContent)
    {
        startPage();
        List<DwTaskContent> list = dwTaskContentService.selectDwTaskContentList(dwTaskContent);
        return getDataTable(list);
    }

    /**
     * 导出考核内容列表
     */
    @PreAuthorize("@ss.hasPermi('examine:content:export')")
    @Log(title = "考核内容", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DwTaskContent dwTaskContent)
    {
        List<DwTaskContent> list = dwTaskContentService.selectDwTaskContentList(dwTaskContent);
        ExcelUtil<DwTaskContent> util = new ExcelUtil<DwTaskContent>(DwTaskContent.class);
        util.exportExcel(response, list, "考核内容数据");
    }

    /**
     * 获取考核内容详细信息
     */
    @PreAuthorize("@ss.hasPermi('examine:content:query')")
    @GetMapping(value = "/{contentId}")
    public AjaxResult getInfo(@PathVariable("contentId") Long contentId)
    {
        return AjaxResult.success(dwTaskContentService.selectDwTaskContentByContentId(contentId));
    }

    /**
     * 新增考核内容
     */
    @PreAuthorize("@ss.hasPermi('examine:content:add')")
    @Log(title = "考核内容", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DwTaskContent dwTaskContent)
    {
        return toAjax(dwTaskContentService.insertDwTaskContent(dwTaskContent));
    }

    /**
     * 修改考核内容
     */
    @PreAuthorize("@ss.hasPermi('examine:content:edit')")
    @Log(title = "考核内容", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DwTaskContent dwTaskContent)
    {
        return toAjax(dwTaskContentService.updateDwTaskContent(dwTaskContent));
    }

    /**
     * 删除考核内容
     */
    @PreAuthorize("@ss.hasPermi('examine:content:remove')")
    @Log(title = "考核内容", businessType = BusinessType.DELETE)
	@DeleteMapping("/{contentIds}")
    public AjaxResult remove(@PathVariable Long[] contentIds)
    {
        return toAjax(dwTaskContentService.deleteDwTaskContentByContentIds(contentIds));
    }
}
